#!/usr/bin/env python
# -*- coding:utf-8 -*-
from datetime import datetime


class ProjectCamObj:
    col_keys = ["name", "camp_sno", "mems_json", "update_date", "create_time"]
    col_def_val = ["", "", None, None, None]

    id: 0
    name: ""
    camp_sno: ""
    mems_json: ""
    update_date: ""
    create_time: ""

    def __init__(self):
        return

    @staticmethod
    def init_dict():
        g_param = {}
        g_param["id"] = 0
        g_param["name"] = ""
        g_param["camp_sno"] = ""
        g_param["mems_json"] = ""
        g_param["update_date"] = ""
        g_param["create_time"] = ""
        return g_param


    @staticmethod
    def split_params(params):
        g_param = []
        if params['name'] is not None and len(params['name']) > 0:
            g_param.append('`name`=' + "\'" + params['name'] + "\'")
        if params['camp_sno'] is not None and len(params['camp_sno']) > 0:
            g_param.append('`camp_sno`=' + "\'" + params['camp_sno'] + "\'")
        if params['mems_json'] is not None and len(params['mems_json']) > 0:
            g_param.append('`mems_json`=' + "\'" + params['mems_json'] + "\'")
        if params['mems_json'] is not None and len(params['mems_json']) > 0:
            g_param.append('`mems_json`=' + "\'" + params['mems_json'] + "\'")
        if params['update_date'] is not None and len(params['update_date']) > 0:
            g_param.append('`update_date`=' + "\'" + params['update_date'] + "\'")
        if params['create_time'] is not None and len(params['create_time']) > 0:
            g_param.append('`create_time`=' + "\'" + params['create_time'] + "\'")
        return ', '.join(str(i) for i in g_param)

    @staticmethod
    def concat_datas(g_param):
        # 获取当前时间
        current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        arry = [g_param["name"], g_param["camp_sno"], g_param["mems_json"], g_param["update_date"], g_param["create_time"]]
        _res = []
        for _val in arry:
            if isinstance(_val, str):
                _res.append(f"\'{_val}\'")
            else:
                if _val is None:
                    _res.append("null")
                else:
                    _res.append(_val)
        return ', '.join(str(i) for i in _res)

    @staticmethod
    def load_db_2_dict(data):
        g_param = {}
        g_param["id"] = data[0]
        g_param["name"] = data[1]
        g_param["camp_sno"] = data[2]
        g_param["mems_json"] = data[3]
        g_param["update_date"] = str(data[4])
        g_param["create_time"] = str(data[5])
        return g_param

    @staticmethod
    def to_string(with_flg):
        g_param = []
        if with_flg:
            g_param.append("`mem_subject_advice`.`name`")
            g_param.append("`mem_subject_advice`.`camp_sno`")
            g_param.append("`mem_subject_advice`.`mems_json`")
            g_param.append("`mem_subject_advice`.`update_date`")
            g_param.append("`mem_subject_advice`.`create_time`")
        else:
            g_param.append("`name`")
            g_param.append("`camp_sno`")
            g_param.append("`mems_json`")
            g_param.append("`update_date`")
            g_param.append("`create_time`")
        return ', '.join(str(i) for i in g_param)
